<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>loanTimeManage.jsp</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="plugins/bootstrap/css/bootstrap.min.css"
	type="text/css"></link>
<link rel="stylesheet" href="plugins/FlatUI/dist/css/flat-ui.css"
	type="text/css"></link>
<link rel="shortcut icon" href="plugins/FlatUI/dist/img/favicon.ico">
<link rel="stylesheet" href="css/style.css">
<script type="text/javascript" src="js/jquery.js">
</script>
<script type="text/javascript" src="plugins/FlatUI/dist/js/flat-ui.js">
</script>
<script type="text/javascript" src="plugins/bootstrap/js/messager.js">
</script>
<script type="text/javascript">
	function modify(loanPeriodWeek, loanPeriodID) {
		alert("loanPeriodID:" + loanPeriodID + "  ,  loanPeriodWeek:" + loanPeriodWeek);
		$("#loanTimeId4Modify").val(loanPeriodID);
		$("#loanTimeName4Modify").val(loanPeriodWeek);
		$('#proModify').modal();
	/* $.ajax({
		url : "updateLoanPeriod.action?loanPeriodID=" + loanPeriodID + "&loanPeriodWeek=" + loanPeriodWeek,
		type : "get",
		dataType : "text",
		success : function(result) {
			if (result == "error") {
				alert("修改贷款周期信息失败!!");
			} else {
				location.href = "selectLoanPeriod.action";
			}
		}
	}); */
	}

	function changeStatus(loanPeriodID, loanPeriodStatus) {
		$.ajax({
			url : "updateLoanPeriodStatus.action?loanPeriodID=" + loanPeriodID + "&loanPeriodStatus=" + loanPeriodStatus,
			type : "get",
			dateType : "text",
			success : function(result) {
				if (result == "error") {
					alert("修改贷款周期状态失败!!");
				} else {
					location.href = "selectLoanPeriod.action";
				}
			}
		});
	}
</script>
</head>
<body style="padding: 5px 10px;">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">贷款周期管理</h3>
		</div>
		<div class="panel-body">
			<a href="javascript:;" class="btn btn-primary btn-default"
				data-toggle="modal" data-target="#proAdd"> 添加 <span
				class="glyphicon glyphicon-plus"></span>
			</a>
			<table class="table table-hover table-bordered">
				<thead>
					<tr>
						<th>贷款周期ID</th>
						<th>周期</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${loanPerionList}" var="loanPeriod">
						<tr>
							<td>${loanPeriod.loanPeriodID}</td>
							<td>${loanPeriod.loanPeriodWeek} 个月</td>
							<td><c:if test="${loanPeriod.loanPeriodStatus==0}">
																	启用
																</c:if> <c:if test="${loanPeriod.loanPeriodStatus==1}">
																	禁用
																</c:if></td>
							<td><a class="btn btn-primary  btn-xs btn-warning"
								href="javascript:;"
								onclick="modify('${loanPeriod.loanPeriodWeek}','${loanPeriod.loanPeriodID}')">
									修改 <span class="glyphicon glyphicon-pencil"></span>
							</a> <c:if test="${loanPeriod.loanPeriodStatus==0}">
									<a class="btn btn-primary btn-xs btn-success"
										href="javascript:;"
										onclick="changeStatus('${loanPeriod.loanPeriodID}','${loanPeriod.loanPeriodStatus}')">
										启用 <span class="glyphicon glyphicon-ok"></span>
									</a>
								</c:if> <c:if test="${loanPeriod.loanPeriodStatus==1}">
									<a class="btn btn-primary btn-xs btn-danger"
										href="javascript:;"
										onclick="changeStatus('${loanPeriod.loanPeriodID}','${loanPeriod.loanPeriodStatus}')">
										禁用 <span class="glyphicon glyphicon-remove"></span>
									</a>
								</c:if></td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
	</div>
	<!-- 产品修改Modal -->
	<div class="modal fade" style="margin-top: 200px;" id="proModify"
		tabindex="-1" role="dialog" aria-labelledby="proModifyLabel"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<form class="form-horizontal" role="form"
					action="updateLoanPeriod.action" method="post">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="myModalLabel">周期修改</h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="loanTimeId4Modify" class="col-lg-2 control-label">
								周期ID </label>
							<div class="col-lg-10">
								<input type="text" class="form-control" id="loanTimeId4Modify"
									name="loanPeriodID" readonly="readonly" />
							</div>
						</div>
						<div class="form-group">
							<label for="loanTimeName4Modify" class="col-lg-2 control-label">
								周期 </label>
							<div class="col-lg-10">
								<input type="text" class="form-control" id="loanTimeName4Modify"
									name="loanPeriodWeek" placeholder="单位：月" />
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							取消</button>
						<input type="submit" class="btn btn-primary" value="修改" />
					</div>
				</form>
			</div>
		</div>
	</div>
	<!-- 产品类型添加Modal -->
	<div class="modal fade" style="margin-top: 200px;" id="proAdd"
		tabindex="-1" role="dialog" aria-labelledby="proAddLabel"
		aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<form class="form-horizontal" role="form"
					action="addLoanPeriod.action" method="post">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal">
							<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
						</button>
						<h4 class="modal-title" id="proAddLabel">周期添加 </h4>
					</div>
					<div class="modal-body">
						<div class="form-group">
							<label for="loanTimeName4Add" class="col-lg-2 control-label">
								周期 </label>
							<div class="col-lg-10">
								<input type="text" class="form-control" id="loanTimeName4Add"
									name="loanPeriodWeek" placeholder="单位：月">
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							取消</button>
						<input type="submit" class="btn btn-primary" value="添加" />
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>
